<?php
/* @var $this MapviewController */

$this->breadcrumbs=array(
	//'Mapview'=>array('/mapview'),
	'Mapview',
);
?>
<h1>Map View of Properties</h1>
<aside>
<!--h4>Search Projects</h4>
<?php echo CHtml::beginForm(array('mapview/index'),'get');?>
<div class="row">Project Name:<?php echo CHtml::textField('projname');?></div>
<!--div class="row">Address:<?php echo CHtml::textField('city');?></div>
<div class="row">City:<?php echo CHtml::textField('province');?></div>
<?php echo CHtml::submitButton('Search');?><br><br-->
<?php echo CHtml::endForm();?>
</aside>
<article>
<?php

Yii::import('ext.egmap.*');
$gMap = new EGMap();
//$gMap->setHeight(500);$gMap->setWidth(1100);
$gMap->zoom = 6;
$mapTypeControlOptions = array(
  'position'=> EGMapControlPosition::LEFT_BOTTOM,
  'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
);
 
$gMap->mapTypeControlOptions= $mapTypeControlOptions;
$gMap->setCenter(12.46876,122.67334);

$info_window_b = new EGMapInfoWindow('Hey! I am a marker with label!');
$icon = new EGMapMarkerImage(Yii::app()->request->baseUrl."/images/home.png");
$icon->setSize(32, 37);
$icon->setAnchor(16, 16.5);
$icon->setOrigin(0, 0);
//echo "<pre>";print_r($projects->search());echo "</pre>";exit;
//$values[] =array();
//echo "<pre>";print_r($projects->search());echo "</pre>";exit;

foreach($projects as $value){
	//echo "<pre>";print_r($value);echo "</pre>";exit;
	$arlatlong = explode(', ',$value->latlng);
	$info_window_a = new EGMapInfoWindow('
	<div>
	<h3>'. $value->name .'</h3>
	'. $value->subtitle .'<br>
	'. CHtml::link('View..',array('project/view','id'=>$value->id)) .'<br>
	</div>
	');
	
	$marker = new EGMapMarker($arlatlong[0], $arlatlong[1], array('title' => $value->name,'icon'=>$icon));
	$marker->addHtmlInfoWindow($info_window_a);
	$gMap->addMarker($marker);
}

$gMap->enableMarkerClusterer(new EGMapMarkerClusterer()); 
$gMap->renderMap();

//echo $this->renderPartial('guestbook/create', array('model'=>$model));
?>
</article>
